package qldc.pm.tiensu.service.persistence;

import com.liferay.portal.kernel.cache.CacheRegistryUtil;
import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.InstanceFactory;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.UnmodifiableList;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.ModelListener;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;

import qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException;
import qldc.pm.tiensu.model.PhieuThongTinVeNguoiCoTienSu;
import qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuImpl;
import qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuModelImpl;
import qldc.pm.tiensu.service.persistence.PhieuThongTinVeNguoiCoTienSuPersistence;

import java.io.Serializable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * The persistence implementation for the phieu thong tin ve nguoi co tien su service.
 *
 * <p>
 * Caching information and settings can be found in <code>portal.properties</code>
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see PhieuThongTinVeNguoiCoTienSuPersistence
 * @see PhieuThongTinVeNguoiCoTienSuUtil
 * @generated
 */
public class PhieuThongTinVeNguoiCoTienSuPersistenceImpl
    extends BasePersistenceImpl<PhieuThongTinVeNguoiCoTienSu>
    implements PhieuThongTinVeNguoiCoTienSuPersistence {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. Always use {@link PhieuThongTinVeNguoiCoTienSuUtil} to access the phieu thong tin ve nguoi co tien su persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
     */
    public static final String FINDER_CLASS_NAME_ENTITY = PhieuThongTinVeNguoiCoTienSuImpl.class.getName();
    public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
        ".List1";
    public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
        ".List2";
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
    public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
    public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
            new String[0]);
    public static final FinderPath FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class, FINDER_CLASS_NAME_ENTITY,
            "fetchByMaSoHoSoTienSuTuToaAn",
            new String[] { String.class.getName() },
            PhieuThongTinVeNguoiCoTienSuModelImpl.MASOHOSOTIENSUTUTOAAN_COLUMN_BITMASK);
    public static final FinderPath FINDER_PATH_COUNT_BY_MASOHOSOTIENSUTUTOAAN = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
            "countByMaSoHoSoTienSuTuToaAn",
            new String[] { String.class.getName() });
    private static final String _FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_1 =
        "phieuThongTinVeNguoiCoTienSu.maSoHoSoTienSuTuToaAn IS NULL";
    private static final String _FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_2 =
        "phieuThongTinVeNguoiCoTienSu.maSoHoSoTienSuTuToaAn = ?";
    private static final String _FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_3 =
        "(phieuThongTinVeNguoiCoTienSu.maSoHoSoTienSuTuToaAn IS NULL OR phieuThongTinVeNguoiCoTienSu.maSoHoSoTienSuTuToaAn = '')";
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SODINHDANHCANHAN =
        new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySoDinhDanhCaNhan",
            new String[] {
                String.class.getName(),
                
            Integer.class.getName(), Integer.class.getName(),
                OrderByComparator.class.getName()
            });
    public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SODINHDANHCANHAN =
        new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
            "findBySoDinhDanhCaNhan", new String[] { String.class.getName() },
            PhieuThongTinVeNguoiCoTienSuModelImpl.SODINHDANHCANHAN_COLUMN_BITMASK |
            PhieuThongTinVeNguoiCoTienSuModelImpl.CREATEDATE_COLUMN_BITMASK);
    public static final FinderPath FINDER_PATH_COUNT_BY_SODINHDANHCANHAN = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
            "countBySoDinhDanhCaNhan", new String[] { String.class.getName() });
    private static final String _FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_1 =
        "phieuThongTinVeNguoiCoTienSu.soDinhDanhCaNhan IS NULL";
    private static final String _FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_2 =
        "phieuThongTinVeNguoiCoTienSu.soDinhDanhCaNhan = ?";
    private static final String _FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_3 =
        "(phieuThongTinVeNguoiCoTienSu.soDinhDanhCaNhan IS NULL OR phieuThongTinVeNguoiCoTienSu.soDinhDanhCaNhan = '')";
    public static final FinderPath FINDER_PATH_FETCH_BY_TIENSUID = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class, FINDER_CLASS_NAME_ENTITY,
            "fetchByTienSuId", new String[] { Long.class.getName() },
            PhieuThongTinVeNguoiCoTienSuModelImpl.TIENSUID_COLUMN_BITMASK);
    public static final FinderPath FINDER_PATH_COUNT_BY_TIENSUID = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
            "countByTienSuId", new String[] { Long.class.getName() });
    private static final String _FINDER_COLUMN_TIENSUID_TIENSUID_2 = "phieuThongTinVeNguoiCoTienSu.tienSuId = ?";
    public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_DIACHI = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByDiaChi",
            new String[] {
                Long.class.getName(), Long.class.getName(), Long.class.getName(),
                String.class.getName(),
                
            Integer.class.getName(), Integer.class.getName(),
                OrderByComparator.class.getName()
            });
    public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DIACHI =
        new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByDiaChi",
            new String[] {
                Long.class.getName(), Long.class.getName(), Long.class.getName(),
                String.class.getName()
            },
            PhieuThongTinVeNguoiCoTienSuModelImpl.NOITHUONGTRUTINHID_COLUMN_BITMASK |
            PhieuThongTinVeNguoiCoTienSuModelImpl.NOITHUONGTRUQUANHUYENID_COLUMN_BITMASK |
            PhieuThongTinVeNguoiCoTienSuModelImpl.NOITHUONGTRUPHUONGXAID_COLUMN_BITMASK |
            PhieuThongTinVeNguoiCoTienSuModelImpl.NOITHUONGTRUDIACHI_COLUMN_BITMASK |
            PhieuThongTinVeNguoiCoTienSuModelImpl.CREATEDATE_COLUMN_BITMASK);
    public static final FinderPath FINDER_PATH_COUNT_BY_DIACHI = new FinderPath(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuModelImpl.FINDER_CACHE_ENABLED,
            Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
            "countByDiaChi",
            new String[] {
                Long.class.getName(), Long.class.getName(), Long.class.getName(),
                String.class.getName()
            });
    private static final String _FINDER_COLUMN_DIACHI_NOITHUONGTRUTINHID_2 = "phieuThongTinVeNguoiCoTienSu.noiThuongTruTinhId = ? AND ";
    private static final String _FINDER_COLUMN_DIACHI_NOITHUONGTRUQUANHUYENID_2 = "phieuThongTinVeNguoiCoTienSu.noiThuongTruQuanHuyenId = ? AND ";
    private static final String _FINDER_COLUMN_DIACHI_NOITHUONGTRUPHUONGXAID_2 = "phieuThongTinVeNguoiCoTienSu.noiThuongTruPhuongXaId = ? AND ";
    private static final String _FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_1 = "phieuThongTinVeNguoiCoTienSu.noiThuongTruDiaChi IS NULL";
    private static final String _FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_2 = "phieuThongTinVeNguoiCoTienSu.noiThuongTruDiaChi = ?";
    private static final String _FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_3 = "(phieuThongTinVeNguoiCoTienSu.noiThuongTruDiaChi IS NULL OR phieuThongTinVeNguoiCoTienSu.noiThuongTruDiaChi = '')";
    private static final String _SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU = "SELECT phieuThongTinVeNguoiCoTienSu FROM PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu";
    private static final String _SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE = "SELECT phieuThongTinVeNguoiCoTienSu FROM PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu WHERE ";
    private static final String _SQL_COUNT_PHIEUTHONGTINVENGUOICOTIENSU = "SELECT COUNT(phieuThongTinVeNguoiCoTienSu) FROM PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu";
    private static final String _SQL_COUNT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE = "SELECT COUNT(phieuThongTinVeNguoiCoTienSu) FROM PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu WHERE ";
    private static final String _ORDER_BY_ENTITY_ALIAS = "phieuThongTinVeNguoiCoTienSu.";
    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PhieuThongTinVeNguoiCoTienSu exists with the primary key ";
    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PhieuThongTinVeNguoiCoTienSu exists with the key {";
    private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = GetterUtil.getBoolean(PropsUtil.get(
                PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
    private static Log _log = LogFactoryUtil.getLog(PhieuThongTinVeNguoiCoTienSuPersistenceImpl.class);
    private static PhieuThongTinVeNguoiCoTienSu _nullPhieuThongTinVeNguoiCoTienSu =
        new PhieuThongTinVeNguoiCoTienSuImpl() {
            @Override
            public Object clone() {
                return this;
            }

            @Override
            public CacheModel<PhieuThongTinVeNguoiCoTienSu> toCacheModel() {
                return _nullPhieuThongTinVeNguoiCoTienSuCacheModel;
            }
        };

    private static CacheModel<PhieuThongTinVeNguoiCoTienSu> _nullPhieuThongTinVeNguoiCoTienSuCacheModel =
        new CacheModel<PhieuThongTinVeNguoiCoTienSu>() {
            @Override
            public PhieuThongTinVeNguoiCoTienSu toEntityModel() {
                return _nullPhieuThongTinVeNguoiCoTienSu;
            }
        };

    public PhieuThongTinVeNguoiCoTienSuPersistenceImpl() {
        setModelClass(PhieuThongTinVeNguoiCoTienSu.class);
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su where maSoHoSoTienSuTuToaAn = &#63; or throws a {@link qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException} if it could not be found.
     *
     * @param maSoHoSoTienSuTuToaAn the ma so ho so tien su tu toa an
     * @return the matching phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findByMaSoHoSoTienSuTuToaAn(
        String maSoHoSoTienSuTuToaAn)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = fetchByMaSoHoSoTienSuTuToaAn(maSoHoSoTienSuTuToaAn);

        if (phieuThongTinVeNguoiCoTienSu == null) {
            StringBundler msg = new StringBundler(4);

            msg.append(_NO_SUCH_ENTITY_WITH_KEY);

            msg.append("maSoHoSoTienSuTuToaAn=");
            msg.append(maSoHoSoTienSuTuToaAn);

            msg.append(StringPool.CLOSE_CURLY_BRACE);

            if (_log.isWarnEnabled()) {
                _log.warn(msg.toString());
            }

            throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(msg.toString());
        }

        return phieuThongTinVeNguoiCoTienSu;
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su where maSoHoSoTienSuTuToaAn = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
     *
     * @param maSoHoSoTienSuTuToaAn the ma so ho so tien su tu toa an
     * @return the matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByMaSoHoSoTienSuTuToaAn(
        String maSoHoSoTienSuTuToaAn) throws SystemException {
        return fetchByMaSoHoSoTienSuTuToaAn(maSoHoSoTienSuTuToaAn, true);
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su where maSoHoSoTienSuTuToaAn = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
     *
     * @param maSoHoSoTienSuTuToaAn the ma so ho so tien su tu toa an
     * @param retrieveFromCache whether to use the finder cache
     * @return the matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByMaSoHoSoTienSuTuToaAn(
        String maSoHoSoTienSuTuToaAn, boolean retrieveFromCache)
        throws SystemException {
        Object[] finderArgs = new Object[] { maSoHoSoTienSuTuToaAn };

        Object result = null;

        if (retrieveFromCache) {
            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
                    finderArgs, this);
        }

        if (result instanceof PhieuThongTinVeNguoiCoTienSu) {
            PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = (PhieuThongTinVeNguoiCoTienSu) result;

            if (!Validator.equals(maSoHoSoTienSuTuToaAn,
                        phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn())) {
                result = null;
            }
        }

        if (result == null) {
            StringBundler query = new StringBundler(3);

            query.append(_SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            boolean bindMaSoHoSoTienSuTuToaAn = false;

            if (maSoHoSoTienSuTuToaAn == null) {
                query.append(_FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_1);
            } else if (maSoHoSoTienSuTuToaAn.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_3);
            } else {
                bindMaSoHoSoTienSuTuToaAn = true;

                query.append(_FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindMaSoHoSoTienSuTuToaAn) {
                    qPos.add(maSoHoSoTienSuTuToaAn);
                }

                List<PhieuThongTinVeNguoiCoTienSu> list = q.list();

                if (list.isEmpty()) {
                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
                        finderArgs, list);
                } else {
                    if ((list.size() > 1) && _log.isWarnEnabled()) {
                        _log.warn(
                            "PhieuThongTinVeNguoiCoTienSuPersistenceImpl.fetchByMaSoHoSoTienSuTuToaAn(String, boolean) with parameters (" +
                            StringUtil.merge(finderArgs) +
                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
                    }

                    PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = list.get(0);

                    result = phieuThongTinVeNguoiCoTienSu;

                    cacheResult(phieuThongTinVeNguoiCoTienSu);

                    if ((phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn() == null) ||
                            !phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn()
                                                             .equals(maSoHoSoTienSuTuToaAn)) {
                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
                            finderArgs, phieuThongTinVeNguoiCoTienSu);
                    }
                }
            } catch (Exception e) {
                FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
                    finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        if (result instanceof List<?>) {
            return null;
        } else {
            return (PhieuThongTinVeNguoiCoTienSu) result;
        }
    }

    /**
     * Removes the phieu thong tin ve nguoi co tien su where maSoHoSoTienSuTuToaAn = &#63; from the database.
     *
     * @param maSoHoSoTienSuTuToaAn the ma so ho so tien su tu toa an
     * @return the phieu thong tin ve nguoi co tien su that was removed
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu removeByMaSoHoSoTienSuTuToaAn(
        String maSoHoSoTienSuTuToaAn)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = findByMaSoHoSoTienSuTuToaAn(maSoHoSoTienSuTuToaAn);

        return remove(phieuThongTinVeNguoiCoTienSu);
    }

    /**
     * Returns the number of phieu thong tin ve nguoi co tien sus where maSoHoSoTienSuTuToaAn = &#63;.
     *
     * @param maSoHoSoTienSuTuToaAn the ma so ho so tien su tu toa an
     * @return the number of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countByMaSoHoSoTienSuTuToaAn(String maSoHoSoTienSuTuToaAn)
        throws SystemException {
        FinderPath finderPath = FINDER_PATH_COUNT_BY_MASOHOSOTIENSUTUTOAAN;

        Object[] finderArgs = new Object[] { maSoHoSoTienSuTuToaAn };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(2);

            query.append(_SQL_COUNT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            boolean bindMaSoHoSoTienSuTuToaAn = false;

            if (maSoHoSoTienSuTuToaAn == null) {
                query.append(_FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_1);
            } else if (maSoHoSoTienSuTuToaAn.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_3);
            } else {
                bindMaSoHoSoTienSuTuToaAn = true;

                query.append(_FINDER_COLUMN_MASOHOSOTIENSUTUTOAAN_MASOHOSOTIENSUTUTOAAN_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindMaSoHoSoTienSuTuToaAn) {
                    qPos.add(maSoHoSoTienSuTuToaAn);
                }

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Returns all the phieu thong tin ve nguoi co tien sus where soDinhDanhCaNhan = &#63;.
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @return the matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findBySoDinhDanhCaNhan(
        String soDinhDanhCaNhan) throws SystemException {
        return findBySoDinhDanhCaNhan(soDinhDanhCaNhan, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS, null);
    }

    /**
     * Returns a range of all the phieu thong tin ve nguoi co tien sus where soDinhDanhCaNhan = &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @param start the lower bound of the range of phieu thong tin ve nguoi co tien sus
     * @param end the upper bound of the range of phieu thong tin ve nguoi co tien sus (not inclusive)
     * @return the range of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findBySoDinhDanhCaNhan(
        String soDinhDanhCaNhan, int start, int end) throws SystemException {
        return findBySoDinhDanhCaNhan(soDinhDanhCaNhan, start, end, null);
    }

    /**
     * Returns an ordered range of all the phieu thong tin ve nguoi co tien sus where soDinhDanhCaNhan = &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @param start the lower bound of the range of phieu thong tin ve nguoi co tien sus
     * @param end the upper bound of the range of phieu thong tin ve nguoi co tien sus (not inclusive)
     * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
     * @return the ordered range of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findBySoDinhDanhCaNhan(
        String soDinhDanhCaNhan, int start, int end,
        OrderByComparator orderByComparator) throws SystemException {
        boolean pagination = true;
        FinderPath finderPath = null;
        Object[] finderArgs = null;

        if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
                (orderByComparator == null)) {
            pagination = false;
            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SODINHDANHCANHAN;
            finderArgs = new Object[] { soDinhDanhCaNhan };
        } else {
            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SODINHDANHCANHAN;
            finderArgs = new Object[] {
                    soDinhDanhCaNhan,
                    
                    start, end, orderByComparator
                };
        }

        List<PhieuThongTinVeNguoiCoTienSu> list = (List<PhieuThongTinVeNguoiCoTienSu>) FinderCacheUtil.getResult(finderPath,
                finderArgs, this);

        if ((list != null) && !list.isEmpty()) {
            for (PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu : list) {
                if (!Validator.equals(soDinhDanhCaNhan,
                            phieuThongTinVeNguoiCoTienSu.getSoDinhDanhCaNhan())) {
                    list = null;

                    break;
                }
            }
        }

        if (list == null) {
            StringBundler query = null;

            if (orderByComparator != null) {
                query = new StringBundler(3 +
                        (orderByComparator.getOrderByFields().length * 3));
            } else {
                query = new StringBundler(3);
            }

            query.append(_SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            boolean bindSoDinhDanhCaNhan = false;

            if (soDinhDanhCaNhan == null) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_1);
            } else if (soDinhDanhCaNhan.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_3);
            } else {
                bindSoDinhDanhCaNhan = true;

                query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_2);
            }

            if (orderByComparator != null) {
                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator);
            } else
             if (pagination) {
                query.append(PhieuThongTinVeNguoiCoTienSuModelImpl.ORDER_BY_JPQL);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoDinhDanhCaNhan) {
                    qPos.add(soDinhDanhCaNhan);
                }

                if (!pagination) {
                    list = (List<PhieuThongTinVeNguoiCoTienSu>) QueryUtil.list(q,
                            getDialect(), start, end, false);

                    Collections.sort(list);

                    list = new UnmodifiableList<PhieuThongTinVeNguoiCoTienSu>(list);
                } else {
                    list = (List<PhieuThongTinVeNguoiCoTienSu>) QueryUtil.list(q,
                            getDialect(), start, end);
                }

                cacheResult(list);

                FinderCacheUtil.putResult(finderPath, finderArgs, list);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return list;
    }

    /**
     * Returns the first phieu thong tin ve nguoi co tien su in the ordered set where soDinhDanhCaNhan = &#63;.
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findBySoDinhDanhCaNhan_First(
        String soDinhDanhCaNhan, OrderByComparator orderByComparator)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = fetchBySoDinhDanhCaNhan_First(soDinhDanhCaNhan,
                orderByComparator);

        if (phieuThongTinVeNguoiCoTienSu != null) {
            return phieuThongTinVeNguoiCoTienSu;
        }

        StringBundler msg = new StringBundler(4);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("soDinhDanhCaNhan=");
        msg.append(soDinhDanhCaNhan);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(msg.toString());
    }

    /**
     * Returns the first phieu thong tin ve nguoi co tien su in the ordered set where soDinhDanhCaNhan = &#63;.
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchBySoDinhDanhCaNhan_First(
        String soDinhDanhCaNhan, OrderByComparator orderByComparator)
        throws SystemException {
        List<PhieuThongTinVeNguoiCoTienSu> list = findBySoDinhDanhCaNhan(soDinhDanhCaNhan,
                0, 1, orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the last phieu thong tin ve nguoi co tien su in the ordered set where soDinhDanhCaNhan = &#63;.
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findBySoDinhDanhCaNhan_Last(
        String soDinhDanhCaNhan, OrderByComparator orderByComparator)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = fetchBySoDinhDanhCaNhan_Last(soDinhDanhCaNhan,
                orderByComparator);

        if (phieuThongTinVeNguoiCoTienSu != null) {
            return phieuThongTinVeNguoiCoTienSu;
        }

        StringBundler msg = new StringBundler(4);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("soDinhDanhCaNhan=");
        msg.append(soDinhDanhCaNhan);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(msg.toString());
    }

    /**
     * Returns the last phieu thong tin ve nguoi co tien su in the ordered set where soDinhDanhCaNhan = &#63;.
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchBySoDinhDanhCaNhan_Last(
        String soDinhDanhCaNhan, OrderByComparator orderByComparator)
        throws SystemException {
        int count = countBySoDinhDanhCaNhan(soDinhDanhCaNhan);

        if (count == 0) {
            return null;
        }

        List<PhieuThongTinVeNguoiCoTienSu> list = findBySoDinhDanhCaNhan(soDinhDanhCaNhan,
                count - 1, count, orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien sus before and after the current phieu thong tin ve nguoi co tien su in the ordered set where soDinhDanhCaNhan = &#63;.
     *
     * @param phieuThongTinVeNguoiCoTienSuId the primary key of the current phieu thong tin ve nguoi co tien su
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the previous, current, and next phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu[] findBySoDinhDanhCaNhan_PrevAndNext(
        long phieuThongTinVeNguoiCoTienSuId, String soDinhDanhCaNhan,
        OrderByComparator orderByComparator)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = findByPrimaryKey(phieuThongTinVeNguoiCoTienSuId);

        Session session = null;

        try {
            session = openSession();

            PhieuThongTinVeNguoiCoTienSu[] array = new PhieuThongTinVeNguoiCoTienSuImpl[3];

            array[0] = getBySoDinhDanhCaNhan_PrevAndNext(session,
                    phieuThongTinVeNguoiCoTienSu, soDinhDanhCaNhan,
                    orderByComparator, true);

            array[1] = phieuThongTinVeNguoiCoTienSu;

            array[2] = getBySoDinhDanhCaNhan_PrevAndNext(session,
                    phieuThongTinVeNguoiCoTienSu, soDinhDanhCaNhan,
                    orderByComparator, false);

            return array;
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    protected PhieuThongTinVeNguoiCoTienSu getBySoDinhDanhCaNhan_PrevAndNext(
        Session session,
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu,
        String soDinhDanhCaNhan, OrderByComparator orderByComparator,
        boolean previous) {
        StringBundler query = null;

        if (orderByComparator != null) {
            query = new StringBundler(6 +
                    (orderByComparator.getOrderByFields().length * 6));
        } else {
            query = new StringBundler(3);
        }

        query.append(_SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

        boolean bindSoDinhDanhCaNhan = false;

        if (soDinhDanhCaNhan == null) {
            query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_1);
        } else if (soDinhDanhCaNhan.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_3);
        } else {
            bindSoDinhDanhCaNhan = true;

            query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_2);
        }

        if (orderByComparator != null) {
            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();

            if (orderByConditionFields.length > 0) {
                query.append(WHERE_AND);
            }

            for (int i = 0; i < orderByConditionFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByConditionFields[i]);

                if ((i + 1) < orderByConditionFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
                    } else {
                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN);
                    } else {
                        query.append(WHERE_LESSER_THAN);
                    }
                }
            }

            query.append(ORDER_BY_CLAUSE);

            String[] orderByFields = orderByComparator.getOrderByFields();

            for (int i = 0; i < orderByFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByFields[i]);

                if ((i + 1) < orderByFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC_HAS_NEXT);
                    } else {
                        query.append(ORDER_BY_DESC_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC);
                    } else {
                        query.append(ORDER_BY_DESC);
                    }
                }
            }
        } else {
            query.append(PhieuThongTinVeNguoiCoTienSuModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Query q = session.createQuery(sql);

        q.setFirstResult(0);
        q.setMaxResults(2);

        QueryPos qPos = QueryPos.getInstance(q);

        if (bindSoDinhDanhCaNhan) {
            qPos.add(soDinhDanhCaNhan);
        }

        if (orderByComparator != null) {
            Object[] values = orderByComparator.getOrderByConditionValues(phieuThongTinVeNguoiCoTienSu);

            for (Object value : values) {
                qPos.add(value);
            }
        }

        List<PhieuThongTinVeNguoiCoTienSu> list = q.list();

        if (list.size() == 2) {
            return list.get(1);
        } else {
            return null;
        }
    }

    /**
     * Removes all the phieu thong tin ve nguoi co tien sus where soDinhDanhCaNhan = &#63; from the database.
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @throws SystemException if a system exception occurred
     */
    @Override
    public void removeBySoDinhDanhCaNhan(String soDinhDanhCaNhan)
        throws SystemException {
        for (PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu : findBySoDinhDanhCaNhan(
                soDinhDanhCaNhan, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
            remove(phieuThongTinVeNguoiCoTienSu);
        }
    }

    /**
     * Returns the number of phieu thong tin ve nguoi co tien sus where soDinhDanhCaNhan = &#63;.
     *
     * @param soDinhDanhCaNhan the so dinh danh ca nhan
     * @return the number of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countBySoDinhDanhCaNhan(String soDinhDanhCaNhan)
        throws SystemException {
        FinderPath finderPath = FINDER_PATH_COUNT_BY_SODINHDANHCANHAN;

        Object[] finderArgs = new Object[] { soDinhDanhCaNhan };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(2);

            query.append(_SQL_COUNT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            boolean bindSoDinhDanhCaNhan = false;

            if (soDinhDanhCaNhan == null) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_1);
            } else if (soDinhDanhCaNhan.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_3);
            } else {
                bindSoDinhDanhCaNhan = true;

                query.append(_FINDER_COLUMN_SODINHDANHCANHAN_SODINHDANHCANHAN_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                if (bindSoDinhDanhCaNhan) {
                    qPos.add(soDinhDanhCaNhan);
                }

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su where tienSuId = &#63; or throws a {@link qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException} if it could not be found.
     *
     * @param tienSuId the tien su ID
     * @return the matching phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findByTienSuId(long tienSuId)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = fetchByTienSuId(tienSuId);

        if (phieuThongTinVeNguoiCoTienSu == null) {
            StringBundler msg = new StringBundler(4);

            msg.append(_NO_SUCH_ENTITY_WITH_KEY);

            msg.append("tienSuId=");
            msg.append(tienSuId);

            msg.append(StringPool.CLOSE_CURLY_BRACE);

            if (_log.isWarnEnabled()) {
                _log.warn(msg.toString());
            }

            throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(msg.toString());
        }

        return phieuThongTinVeNguoiCoTienSu;
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su where tienSuId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
     *
     * @param tienSuId the tien su ID
     * @return the matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByTienSuId(long tienSuId)
        throws SystemException {
        return fetchByTienSuId(tienSuId, true);
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su where tienSuId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
     *
     * @param tienSuId the tien su ID
     * @param retrieveFromCache whether to use the finder cache
     * @return the matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByTienSuId(long tienSuId,
        boolean retrieveFromCache) throws SystemException {
        Object[] finderArgs = new Object[] { tienSuId };

        Object result = null;

        if (retrieveFromCache) {
            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_TIENSUID,
                    finderArgs, this);
        }

        if (result instanceof PhieuThongTinVeNguoiCoTienSu) {
            PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = (PhieuThongTinVeNguoiCoTienSu) result;

            if ((tienSuId != phieuThongTinVeNguoiCoTienSu.getTienSuId())) {
                result = null;
            }
        }

        if (result == null) {
            StringBundler query = new StringBundler(3);

            query.append(_SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            query.append(_FINDER_COLUMN_TIENSUID_TIENSUID_2);

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                qPos.add(tienSuId);

                List<PhieuThongTinVeNguoiCoTienSu> list = q.list();

                if (list.isEmpty()) {
                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TIENSUID,
                        finderArgs, list);
                } else {
                    if ((list.size() > 1) && _log.isWarnEnabled()) {
                        _log.warn(
                            "PhieuThongTinVeNguoiCoTienSuPersistenceImpl.fetchByTienSuId(long, boolean) with parameters (" +
                            StringUtil.merge(finderArgs) +
                            ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
                    }

                    PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = list.get(0);

                    result = phieuThongTinVeNguoiCoTienSu;

                    cacheResult(phieuThongTinVeNguoiCoTienSu);

                    if ((phieuThongTinVeNguoiCoTienSu.getTienSuId() != tienSuId)) {
                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TIENSUID,
                            finderArgs, phieuThongTinVeNguoiCoTienSu);
                    }
                }
            } catch (Exception e) {
                FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_TIENSUID,
                    finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        if (result instanceof List<?>) {
            return null;
        } else {
            return (PhieuThongTinVeNguoiCoTienSu) result;
        }
    }

    /**
     * Removes the phieu thong tin ve nguoi co tien su where tienSuId = &#63; from the database.
     *
     * @param tienSuId the tien su ID
     * @return the phieu thong tin ve nguoi co tien su that was removed
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu removeByTienSuId(long tienSuId)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = findByTienSuId(tienSuId);

        return remove(phieuThongTinVeNguoiCoTienSu);
    }

    /**
     * Returns the number of phieu thong tin ve nguoi co tien sus where tienSuId = &#63;.
     *
     * @param tienSuId the tien su ID
     * @return the number of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countByTienSuId(long tienSuId) throws SystemException {
        FinderPath finderPath = FINDER_PATH_COUNT_BY_TIENSUID;

        Object[] finderArgs = new Object[] { tienSuId };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(2);

            query.append(_SQL_COUNT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            query.append(_FINDER_COLUMN_TIENSUID_TIENSUID_2);

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                qPos.add(tienSuId);

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Returns all the phieu thong tin ve nguoi co tien sus where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @return the matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findByDiaChi(
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi)
        throws SystemException {
        return findByDiaChi(noiThuongTruTinhId, noiThuongTruQuanHuyenId,
            noiThuongTruPhuongXaId, noiThuongTruDiaChi, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS, null);
    }

    /**
     * Returns a range of all the phieu thong tin ve nguoi co tien sus where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @param start the lower bound of the range of phieu thong tin ve nguoi co tien sus
     * @param end the upper bound of the range of phieu thong tin ve nguoi co tien sus (not inclusive)
     * @return the range of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findByDiaChi(
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi, int start,
        int end) throws SystemException {
        return findByDiaChi(noiThuongTruTinhId, noiThuongTruQuanHuyenId,
            noiThuongTruPhuongXaId, noiThuongTruDiaChi, start, end, null);
    }

    /**
     * Returns an ordered range of all the phieu thong tin ve nguoi co tien sus where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @param start the lower bound of the range of phieu thong tin ve nguoi co tien sus
     * @param end the upper bound of the range of phieu thong tin ve nguoi co tien sus (not inclusive)
     * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
     * @return the ordered range of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findByDiaChi(
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi, int start,
        int end, OrderByComparator orderByComparator) throws SystemException {
        boolean pagination = true;
        FinderPath finderPath = null;
        Object[] finderArgs = null;

        if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
                (orderByComparator == null)) {
            pagination = false;
            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DIACHI;
            finderArgs = new Object[] {
                    noiThuongTruTinhId, noiThuongTruQuanHuyenId,
                    noiThuongTruPhuongXaId, noiThuongTruDiaChi
                };
        } else {
            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_DIACHI;
            finderArgs = new Object[] {
                    noiThuongTruTinhId, noiThuongTruQuanHuyenId,
                    noiThuongTruPhuongXaId, noiThuongTruDiaChi,
                    
                    start, end, orderByComparator
                };
        }

        List<PhieuThongTinVeNguoiCoTienSu> list = (List<PhieuThongTinVeNguoiCoTienSu>) FinderCacheUtil.getResult(finderPath,
                finderArgs, this);

        if ((list != null) && !list.isEmpty()) {
            for (PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu : list) {
                if ((noiThuongTruTinhId != phieuThongTinVeNguoiCoTienSu.getNoiThuongTruTinhId()) ||
                        (noiThuongTruQuanHuyenId != phieuThongTinVeNguoiCoTienSu.getNoiThuongTruQuanHuyenId()) ||
                        (noiThuongTruPhuongXaId != phieuThongTinVeNguoiCoTienSu.getNoiThuongTruPhuongXaId()) ||
                        !Validator.equals(noiThuongTruDiaChi,
                            phieuThongTinVeNguoiCoTienSu.getNoiThuongTruDiaChi())) {
                    list = null;

                    break;
                }
            }
        }

        if (list == null) {
            StringBundler query = null;

            if (orderByComparator != null) {
                query = new StringBundler(6 +
                        (orderByComparator.getOrderByFields().length * 3));
            } else {
                query = new StringBundler(6);
            }

            query.append(_SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUTINHID_2);

            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUQUANHUYENID_2);

            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUPHUONGXAID_2);

            boolean bindNoiThuongTruDiaChi = false;

            if (noiThuongTruDiaChi == null) {
                query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_1);
            } else if (noiThuongTruDiaChi.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_3);
            } else {
                bindNoiThuongTruDiaChi = true;

                query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_2);
            }

            if (orderByComparator != null) {
                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator);
            } else
             if (pagination) {
                query.append(PhieuThongTinVeNguoiCoTienSuModelImpl.ORDER_BY_JPQL);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                qPos.add(noiThuongTruTinhId);

                qPos.add(noiThuongTruQuanHuyenId);

                qPos.add(noiThuongTruPhuongXaId);

                if (bindNoiThuongTruDiaChi) {
                    qPos.add(noiThuongTruDiaChi);
                }

                if (!pagination) {
                    list = (List<PhieuThongTinVeNguoiCoTienSu>) QueryUtil.list(q,
                            getDialect(), start, end, false);

                    Collections.sort(list);

                    list = new UnmodifiableList<PhieuThongTinVeNguoiCoTienSu>(list);
                } else {
                    list = (List<PhieuThongTinVeNguoiCoTienSu>) QueryUtil.list(q,
                            getDialect(), start, end);
                }

                cacheResult(list);

                FinderCacheUtil.putResult(finderPath, finderArgs, list);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return list;
    }

    /**
     * Returns the first phieu thong tin ve nguoi co tien su in the ordered set where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findByDiaChi_First(
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi,
        OrderByComparator orderByComparator)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = fetchByDiaChi_First(noiThuongTruTinhId,
                noiThuongTruQuanHuyenId, noiThuongTruPhuongXaId,
                noiThuongTruDiaChi, orderByComparator);

        if (phieuThongTinVeNguoiCoTienSu != null) {
            return phieuThongTinVeNguoiCoTienSu;
        }

        StringBundler msg = new StringBundler(10);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("noiThuongTruTinhId=");
        msg.append(noiThuongTruTinhId);

        msg.append(", noiThuongTruQuanHuyenId=");
        msg.append(noiThuongTruQuanHuyenId);

        msg.append(", noiThuongTruPhuongXaId=");
        msg.append(noiThuongTruPhuongXaId);

        msg.append(", noiThuongTruDiaChi=");
        msg.append(noiThuongTruDiaChi);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(msg.toString());
    }

    /**
     * Returns the first phieu thong tin ve nguoi co tien su in the ordered set where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the first matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByDiaChi_First(
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi,
        OrderByComparator orderByComparator) throws SystemException {
        List<PhieuThongTinVeNguoiCoTienSu> list = findByDiaChi(noiThuongTruTinhId,
                noiThuongTruQuanHuyenId, noiThuongTruPhuongXaId,
                noiThuongTruDiaChi, 0, 1, orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the last phieu thong tin ve nguoi co tien su in the ordered set where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findByDiaChi_Last(
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi,
        OrderByComparator orderByComparator)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = fetchByDiaChi_Last(noiThuongTruTinhId,
                noiThuongTruQuanHuyenId, noiThuongTruPhuongXaId,
                noiThuongTruDiaChi, orderByComparator);

        if (phieuThongTinVeNguoiCoTienSu != null) {
            return phieuThongTinVeNguoiCoTienSu;
        }

        StringBundler msg = new StringBundler(10);

        msg.append(_NO_SUCH_ENTITY_WITH_KEY);

        msg.append("noiThuongTruTinhId=");
        msg.append(noiThuongTruTinhId);

        msg.append(", noiThuongTruQuanHuyenId=");
        msg.append(noiThuongTruQuanHuyenId);

        msg.append(", noiThuongTruPhuongXaId=");
        msg.append(noiThuongTruPhuongXaId);

        msg.append(", noiThuongTruDiaChi=");
        msg.append(noiThuongTruDiaChi);

        msg.append(StringPool.CLOSE_CURLY_BRACE);

        throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(msg.toString());
    }

    /**
     * Returns the last phieu thong tin ve nguoi co tien su in the ordered set where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the last matching phieu thong tin ve nguoi co tien su, or <code>null</code> if a matching phieu thong tin ve nguoi co tien su could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByDiaChi_Last(
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi,
        OrderByComparator orderByComparator) throws SystemException {
        int count = countByDiaChi(noiThuongTruTinhId, noiThuongTruQuanHuyenId,
                noiThuongTruPhuongXaId, noiThuongTruDiaChi);

        if (count == 0) {
            return null;
        }

        List<PhieuThongTinVeNguoiCoTienSu> list = findByDiaChi(noiThuongTruTinhId,
                noiThuongTruQuanHuyenId, noiThuongTruPhuongXaId,
                noiThuongTruDiaChi, count - 1, count, orderByComparator);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien sus before and after the current phieu thong tin ve nguoi co tien su in the ordered set where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * @param phieuThongTinVeNguoiCoTienSuId the primary key of the current phieu thong tin ve nguoi co tien su
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
     * @return the previous, current, and next phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu[] findByDiaChi_PrevAndNext(
        long phieuThongTinVeNguoiCoTienSuId, long noiThuongTruTinhId,
        long noiThuongTruQuanHuyenId, long noiThuongTruPhuongXaId,
        String noiThuongTruDiaChi, OrderByComparator orderByComparator)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = findByPrimaryKey(phieuThongTinVeNguoiCoTienSuId);

        Session session = null;

        try {
            session = openSession();

            PhieuThongTinVeNguoiCoTienSu[] array = new PhieuThongTinVeNguoiCoTienSuImpl[3];

            array[0] = getByDiaChi_PrevAndNext(session,
                    phieuThongTinVeNguoiCoTienSu, noiThuongTruTinhId,
                    noiThuongTruQuanHuyenId, noiThuongTruPhuongXaId,
                    noiThuongTruDiaChi, orderByComparator, true);

            array[1] = phieuThongTinVeNguoiCoTienSu;

            array[2] = getByDiaChi_PrevAndNext(session,
                    phieuThongTinVeNguoiCoTienSu, noiThuongTruTinhId,
                    noiThuongTruQuanHuyenId, noiThuongTruPhuongXaId,
                    noiThuongTruDiaChi, orderByComparator, false);

            return array;
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    protected PhieuThongTinVeNguoiCoTienSu getByDiaChi_PrevAndNext(
        Session session,
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu,
        long noiThuongTruTinhId, long noiThuongTruQuanHuyenId,
        long noiThuongTruPhuongXaId, String noiThuongTruDiaChi,
        OrderByComparator orderByComparator, boolean previous) {
        StringBundler query = null;

        if (orderByComparator != null) {
            query = new StringBundler(6 +
                    (orderByComparator.getOrderByFields().length * 6));
        } else {
            query = new StringBundler(3);
        }

        query.append(_SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

        query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUTINHID_2);

        query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUQUANHUYENID_2);

        query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUPHUONGXAID_2);

        boolean bindNoiThuongTruDiaChi = false;

        if (noiThuongTruDiaChi == null) {
            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_1);
        } else if (noiThuongTruDiaChi.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_3);
        } else {
            bindNoiThuongTruDiaChi = true;

            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_2);
        }

        if (orderByComparator != null) {
            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();

            if (orderByConditionFields.length > 0) {
                query.append(WHERE_AND);
            }

            for (int i = 0; i < orderByConditionFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByConditionFields[i]);

                if ((i + 1) < orderByConditionFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN_HAS_NEXT);
                    } else {
                        query.append(WHERE_LESSER_THAN_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(WHERE_GREATER_THAN);
                    } else {
                        query.append(WHERE_LESSER_THAN);
                    }
                }
            }

            query.append(ORDER_BY_CLAUSE);

            String[] orderByFields = orderByComparator.getOrderByFields();

            for (int i = 0; i < orderByFields.length; i++) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
                query.append(orderByFields[i]);

                if ((i + 1) < orderByFields.length) {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC_HAS_NEXT);
                    } else {
                        query.append(ORDER_BY_DESC_HAS_NEXT);
                    }
                } else {
                    if (orderByComparator.isAscending() ^ previous) {
                        query.append(ORDER_BY_ASC);
                    } else {
                        query.append(ORDER_BY_DESC);
                    }
                }
            }
        } else {
            query.append(PhieuThongTinVeNguoiCoTienSuModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Query q = session.createQuery(sql);

        q.setFirstResult(0);
        q.setMaxResults(2);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(noiThuongTruTinhId);

        qPos.add(noiThuongTruQuanHuyenId);

        qPos.add(noiThuongTruPhuongXaId);

        if (bindNoiThuongTruDiaChi) {
            qPos.add(noiThuongTruDiaChi);
        }

        if (orderByComparator != null) {
            Object[] values = orderByComparator.getOrderByConditionValues(phieuThongTinVeNguoiCoTienSu);

            for (Object value : values) {
                qPos.add(value);
            }
        }

        List<PhieuThongTinVeNguoiCoTienSu> list = q.list();

        if (list.size() == 2) {
            return list.get(1);
        } else {
            return null;
        }
    }

    /**
     * Removes all the phieu thong tin ve nguoi co tien sus where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63; from the database.
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @throws SystemException if a system exception occurred
     */
    @Override
    public void removeByDiaChi(long noiThuongTruTinhId,
        long noiThuongTruQuanHuyenId, long noiThuongTruPhuongXaId,
        String noiThuongTruDiaChi) throws SystemException {
        for (PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu : findByDiaChi(
                noiThuongTruTinhId, noiThuongTruQuanHuyenId,
                noiThuongTruPhuongXaId, noiThuongTruDiaChi, QueryUtil.ALL_POS,
                QueryUtil.ALL_POS, null)) {
            remove(phieuThongTinVeNguoiCoTienSu);
        }
    }

    /**
     * Returns the number of phieu thong tin ve nguoi co tien sus where noiThuongTruTinhId = &#63; and noiThuongTruQuanHuyenId = &#63; and noiThuongTruPhuongXaId = &#63; and noiThuongTruDiaChi = &#63;.
     *
     * @param noiThuongTruTinhId the noi thuong tru tinh ID
     * @param noiThuongTruQuanHuyenId the noi thuong tru quan huyen ID
     * @param noiThuongTruPhuongXaId the noi thuong tru phuong xa ID
     * @param noiThuongTruDiaChi the noi thuong tru dia chi
     * @return the number of matching phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countByDiaChi(long noiThuongTruTinhId,
        long noiThuongTruQuanHuyenId, long noiThuongTruPhuongXaId,
        String noiThuongTruDiaChi) throws SystemException {
        FinderPath finderPath = FINDER_PATH_COUNT_BY_DIACHI;

        Object[] finderArgs = new Object[] {
                noiThuongTruTinhId, noiThuongTruQuanHuyenId,
                noiThuongTruPhuongXaId, noiThuongTruDiaChi
            };

        Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs,
                this);

        if (count == null) {
            StringBundler query = new StringBundler(5);

            query.append(_SQL_COUNT_PHIEUTHONGTINVENGUOICOTIENSU_WHERE);

            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUTINHID_2);

            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUQUANHUYENID_2);

            query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUPHUONGXAID_2);

            boolean bindNoiThuongTruDiaChi = false;

            if (noiThuongTruDiaChi == null) {
                query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_1);
            } else if (noiThuongTruDiaChi.equals(StringPool.BLANK)) {
                query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_3);
            } else {
                bindNoiThuongTruDiaChi = true;

                query.append(_FINDER_COLUMN_DIACHI_NOITHUONGTRUDIACHI_2);
            }

            String sql = query.toString();

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                QueryPos qPos = QueryPos.getInstance(q);

                qPos.add(noiThuongTruTinhId);

                qPos.add(noiThuongTruQuanHuyenId);

                qPos.add(noiThuongTruPhuongXaId);

                if (bindNoiThuongTruDiaChi) {
                    qPos.add(noiThuongTruDiaChi);
                }

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(finderPath, finderArgs, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Caches the phieu thong tin ve nguoi co tien su in the entity cache if it is enabled.
     *
     * @param phieuThongTinVeNguoiCoTienSu the phieu thong tin ve nguoi co tien su
     */
    @Override
    public void cacheResult(
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu) {
        EntityCacheUtil.putResult(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            phieuThongTinVeNguoiCoTienSu.getPrimaryKey(),
            phieuThongTinVeNguoiCoTienSu);

        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
            new Object[] { phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn() },
            phieuThongTinVeNguoiCoTienSu);

        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TIENSUID,
            new Object[] { phieuThongTinVeNguoiCoTienSu.getTienSuId() },
            phieuThongTinVeNguoiCoTienSu);

        phieuThongTinVeNguoiCoTienSu.resetOriginalValues();
    }

    /**
     * Caches the phieu thong tin ve nguoi co tien sus in the entity cache if it is enabled.
     *
     * @param phieuThongTinVeNguoiCoTienSus the phieu thong tin ve nguoi co tien sus
     */
    @Override
    public void cacheResult(
        List<PhieuThongTinVeNguoiCoTienSu> phieuThongTinVeNguoiCoTienSus) {
        for (PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu : phieuThongTinVeNguoiCoTienSus) {
            if (EntityCacheUtil.getResult(
                        PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
                        PhieuThongTinVeNguoiCoTienSuImpl.class,
                        phieuThongTinVeNguoiCoTienSu.getPrimaryKey()) == null) {
                cacheResult(phieuThongTinVeNguoiCoTienSu);
            } else {
                phieuThongTinVeNguoiCoTienSu.resetOriginalValues();
            }
        }
    }

    /**
     * Clears the cache for all phieu thong tin ve nguoi co tien sus.
     *
     * <p>
     * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
     * </p>
     */
    @Override
    public void clearCache() {
        if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
            CacheRegistryUtil.clear(PhieuThongTinVeNguoiCoTienSuImpl.class.getName());
        }

        EntityCacheUtil.clearCache(PhieuThongTinVeNguoiCoTienSuImpl.class.getName());

        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    /**
     * Clears the cache for the phieu thong tin ve nguoi co tien su.
     *
     * <p>
     * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
     * </p>
     */
    @Override
    public void clearCache(
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu) {
        EntityCacheUtil.removeResult(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            phieuThongTinVeNguoiCoTienSu.getPrimaryKey());

        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

        clearUniqueFindersCache(phieuThongTinVeNguoiCoTienSu);
    }

    @Override
    public void clearCache(
        List<PhieuThongTinVeNguoiCoTienSu> phieuThongTinVeNguoiCoTienSus) {
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

        for (PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu : phieuThongTinVeNguoiCoTienSus) {
            EntityCacheUtil.removeResult(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
                PhieuThongTinVeNguoiCoTienSuImpl.class,
                phieuThongTinVeNguoiCoTienSu.getPrimaryKey());

            clearUniqueFindersCache(phieuThongTinVeNguoiCoTienSu);
        }
    }

    protected void cacheUniqueFindersCache(
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu) {
        if (phieuThongTinVeNguoiCoTienSu.isNew()) {
            Object[] args = new Object[] {
                    phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn()
                };

            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MASOHOSOTIENSUTUTOAAN,
                args, Long.valueOf(1));
            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
                args, phieuThongTinVeNguoiCoTienSu);

            args = new Object[] { phieuThongTinVeNguoiCoTienSu.getTienSuId() };

            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TIENSUID, args,
                Long.valueOf(1));
            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TIENSUID, args,
                phieuThongTinVeNguoiCoTienSu);
        } else {
            PhieuThongTinVeNguoiCoTienSuModelImpl phieuThongTinVeNguoiCoTienSuModelImpl =
                (PhieuThongTinVeNguoiCoTienSuModelImpl) phieuThongTinVeNguoiCoTienSu;

            if ((phieuThongTinVeNguoiCoTienSuModelImpl.getColumnBitmask() &
                    FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN.getColumnBitmask()) != 0) {
                Object[] args = new Object[] {
                        phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn()
                    };

                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MASOHOSOTIENSUTUTOAAN,
                    args, Long.valueOf(1));
                FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
                    args, phieuThongTinVeNguoiCoTienSu);
            }

            if ((phieuThongTinVeNguoiCoTienSuModelImpl.getColumnBitmask() &
                    FINDER_PATH_FETCH_BY_TIENSUID.getColumnBitmask()) != 0) {
                Object[] args = new Object[] {
                        phieuThongTinVeNguoiCoTienSu.getTienSuId()
                    };

                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TIENSUID, args,
                    Long.valueOf(1));
                FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TIENSUID, args,
                    phieuThongTinVeNguoiCoTienSu);
            }
        }
    }

    protected void clearUniqueFindersCache(
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu) {
        PhieuThongTinVeNguoiCoTienSuModelImpl phieuThongTinVeNguoiCoTienSuModelImpl =
            (PhieuThongTinVeNguoiCoTienSuModelImpl) phieuThongTinVeNguoiCoTienSu;

        Object[] args = new Object[] {
                phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn()
            };

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MASOHOSOTIENSUTUTOAAN,
            args);
        FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
            args);

        if ((phieuThongTinVeNguoiCoTienSuModelImpl.getColumnBitmask() &
                FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN.getColumnBitmask()) != 0) {
            args = new Object[] {
                    phieuThongTinVeNguoiCoTienSuModelImpl.getOriginalMaSoHoSoTienSuTuToaAn()
                };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MASOHOSOTIENSUTUTOAAN,
                args);
            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MASOHOSOTIENSUTUTOAAN,
                args);
        }

        args = new Object[] { phieuThongTinVeNguoiCoTienSu.getTienSuId() };

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TIENSUID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_TIENSUID, args);

        if ((phieuThongTinVeNguoiCoTienSuModelImpl.getColumnBitmask() &
                FINDER_PATH_FETCH_BY_TIENSUID.getColumnBitmask()) != 0) {
            args = new Object[] {
                    phieuThongTinVeNguoiCoTienSuModelImpl.getOriginalTienSuId()
                };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TIENSUID, args);
            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_TIENSUID, args);
        }
    }

    /**
     * Creates a new phieu thong tin ve nguoi co tien su with the primary key. Does not add the phieu thong tin ve nguoi co tien su to the database.
     *
     * @param phieuThongTinVeNguoiCoTienSuId the primary key for the new phieu thong tin ve nguoi co tien su
     * @return the new phieu thong tin ve nguoi co tien su
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu create(
        long phieuThongTinVeNguoiCoTienSuId) {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = new PhieuThongTinVeNguoiCoTienSuImpl();

        phieuThongTinVeNguoiCoTienSu.setNew(true);
        phieuThongTinVeNguoiCoTienSu.setPrimaryKey(phieuThongTinVeNguoiCoTienSuId);

        return phieuThongTinVeNguoiCoTienSu;
    }

    /**
     * Removes the phieu thong tin ve nguoi co tien su with the primary key from the database. Also notifies the appropriate model listeners.
     *
     * @param phieuThongTinVeNguoiCoTienSuId the primary key of the phieu thong tin ve nguoi co tien su
     * @return the phieu thong tin ve nguoi co tien su that was removed
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu remove(
        long phieuThongTinVeNguoiCoTienSuId)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        return remove((Serializable) phieuThongTinVeNguoiCoTienSuId);
    }

    /**
     * Removes the phieu thong tin ve nguoi co tien su with the primary key from the database. Also notifies the appropriate model listeners.
     *
     * @param primaryKey the primary key of the phieu thong tin ve nguoi co tien su
     * @return the phieu thong tin ve nguoi co tien su that was removed
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu remove(Serializable primaryKey)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        Session session = null;

        try {
            session = openSession();

            PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = (PhieuThongTinVeNguoiCoTienSu) session.get(PhieuThongTinVeNguoiCoTienSuImpl.class,
                    primaryKey);

            if (phieuThongTinVeNguoiCoTienSu == null) {
                if (_log.isWarnEnabled()) {
                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
                }

                throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
                    primaryKey);
            }

            return remove(phieuThongTinVeNguoiCoTienSu);
        } catch (NoSuchPhieuThongTinVeNguoiCoTienSuException nsee) {
            throw nsee;
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    @Override
    protected PhieuThongTinVeNguoiCoTienSu removeImpl(
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu)
        throws SystemException {
        phieuThongTinVeNguoiCoTienSu = toUnwrappedModel(phieuThongTinVeNguoiCoTienSu);

        Session session = null;

        try {
            session = openSession();

            if (!session.contains(phieuThongTinVeNguoiCoTienSu)) {
                phieuThongTinVeNguoiCoTienSu = (PhieuThongTinVeNguoiCoTienSu) session.get(PhieuThongTinVeNguoiCoTienSuImpl.class,
                        phieuThongTinVeNguoiCoTienSu.getPrimaryKeyObj());
            }

            if (phieuThongTinVeNguoiCoTienSu != null) {
                session.delete(phieuThongTinVeNguoiCoTienSu);
            }
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }

        if (phieuThongTinVeNguoiCoTienSu != null) {
            clearCache(phieuThongTinVeNguoiCoTienSu);
        }

        return phieuThongTinVeNguoiCoTienSu;
    }

    @Override
    public PhieuThongTinVeNguoiCoTienSu updateImpl(
        qldc.pm.tiensu.model.PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu)
        throws SystemException {
        phieuThongTinVeNguoiCoTienSu = toUnwrappedModel(phieuThongTinVeNguoiCoTienSu);

        boolean isNew = phieuThongTinVeNguoiCoTienSu.isNew();

        PhieuThongTinVeNguoiCoTienSuModelImpl phieuThongTinVeNguoiCoTienSuModelImpl =
            (PhieuThongTinVeNguoiCoTienSuModelImpl) phieuThongTinVeNguoiCoTienSu;

        Session session = null;

        try {
            session = openSession();

            if (phieuThongTinVeNguoiCoTienSu.isNew()) {
                session.save(phieuThongTinVeNguoiCoTienSu);

                phieuThongTinVeNguoiCoTienSu.setNew(false);
            } else {
                session.merge(phieuThongTinVeNguoiCoTienSu);
            }
        } catch (Exception e) {
            throw processException(e);
        } finally {
            closeSession(session);
        }

        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

        if (isNew ||
                !PhieuThongTinVeNguoiCoTienSuModelImpl.COLUMN_BITMASK_ENABLED) {
            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
        }
        else {
            if ((phieuThongTinVeNguoiCoTienSuModelImpl.getColumnBitmask() &
                    FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SODINHDANHCANHAN.getColumnBitmask()) != 0) {
                Object[] args = new Object[] {
                        phieuThongTinVeNguoiCoTienSuModelImpl.getOriginalSoDinhDanhCaNhan()
                    };

                FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SODINHDANHCANHAN,
                    args);
                FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SODINHDANHCANHAN,
                    args);

                args = new Object[] {
                        phieuThongTinVeNguoiCoTienSuModelImpl.getSoDinhDanhCaNhan()
                    };

                FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SODINHDANHCANHAN,
                    args);
                FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SODINHDANHCANHAN,
                    args);
            }

            if ((phieuThongTinVeNguoiCoTienSuModelImpl.getColumnBitmask() &
                    FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DIACHI.getColumnBitmask()) != 0) {
                Object[] args = new Object[] {
                        phieuThongTinVeNguoiCoTienSuModelImpl.getOriginalNoiThuongTruTinhId(),
                        phieuThongTinVeNguoiCoTienSuModelImpl.getOriginalNoiThuongTruQuanHuyenId(),
                        phieuThongTinVeNguoiCoTienSuModelImpl.getOriginalNoiThuongTruPhuongXaId(),
                        phieuThongTinVeNguoiCoTienSuModelImpl.getOriginalNoiThuongTruDiaChi()
                    };

                FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DIACHI, args);
                FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DIACHI,
                    args);

                args = new Object[] {
                        phieuThongTinVeNguoiCoTienSuModelImpl.getNoiThuongTruTinhId(),
                        phieuThongTinVeNguoiCoTienSuModelImpl.getNoiThuongTruQuanHuyenId(),
                        phieuThongTinVeNguoiCoTienSuModelImpl.getNoiThuongTruPhuongXaId(),
                        phieuThongTinVeNguoiCoTienSuModelImpl.getNoiThuongTruDiaChi()
                    };

                FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DIACHI, args);
                FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DIACHI,
                    args);
            }
        }

        EntityCacheUtil.putResult(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
            PhieuThongTinVeNguoiCoTienSuImpl.class,
            phieuThongTinVeNguoiCoTienSu.getPrimaryKey(),
            phieuThongTinVeNguoiCoTienSu);

        clearUniqueFindersCache(phieuThongTinVeNguoiCoTienSu);
        cacheUniqueFindersCache(phieuThongTinVeNguoiCoTienSu);

        return phieuThongTinVeNguoiCoTienSu;
    }

    protected PhieuThongTinVeNguoiCoTienSu toUnwrappedModel(
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu) {
        if (phieuThongTinVeNguoiCoTienSu instanceof PhieuThongTinVeNguoiCoTienSuImpl) {
            return phieuThongTinVeNguoiCoTienSu;
        }

        PhieuThongTinVeNguoiCoTienSuImpl phieuThongTinVeNguoiCoTienSuImpl = new PhieuThongTinVeNguoiCoTienSuImpl();

        phieuThongTinVeNguoiCoTienSuImpl.setNew(phieuThongTinVeNguoiCoTienSu.isNew());
        phieuThongTinVeNguoiCoTienSuImpl.setPrimaryKey(phieuThongTinVeNguoiCoTienSu.getPrimaryKey());

        phieuThongTinVeNguoiCoTienSuImpl.setPhieuThongTinVeNguoiCoTienSuId(phieuThongTinVeNguoiCoTienSu.getPhieuThongTinVeNguoiCoTienSuId());
        phieuThongTinVeNguoiCoTienSuImpl.setUserId(phieuThongTinVeNguoiCoTienSu.getUserId());
        phieuThongTinVeNguoiCoTienSuImpl.setUserName(phieuThongTinVeNguoiCoTienSu.getUserName());
        phieuThongTinVeNguoiCoTienSuImpl.setCreateDate(phieuThongTinVeNguoiCoTienSu.getCreateDate());
        phieuThongTinVeNguoiCoTienSuImpl.setModifiedDate(phieuThongTinVeNguoiCoTienSu.getModifiedDate());
        phieuThongTinVeNguoiCoTienSuImpl.setTienSuId(phieuThongTinVeNguoiCoTienSu.getTienSuId());
        phieuThongTinVeNguoiCoTienSuImpl.setMaSoHoSoTienSuTuToaAn(phieuThongTinVeNguoiCoTienSu.getMaSoHoSoTienSuTuToaAn());
        phieuThongTinVeNguoiCoTienSuImpl.setNguoiTrichLuc(phieuThongTinVeNguoiCoTienSu.getNguoiTrichLuc());
        phieuThongTinVeNguoiCoTienSuImpl.setThamPhan(phieuThongTinVeNguoiCoTienSu.getThamPhan());
        phieuThongTinVeNguoiCoTienSuImpl.setSoDinhDanhCaNhan(phieuThongTinVeNguoiCoTienSu.getSoDinhDanhCaNhan());
        phieuThongTinVeNguoiCoTienSuImpl.setChuThich(phieuThongTinVeNguoiCoTienSu.getChuThich());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiTamTruDiaChi(phieuThongTinVeNguoiCoTienSu.getNoiTamTruDiaChi());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiTamTruTinhId(phieuThongTinVeNguoiCoTienSu.getNoiTamTruTinhId());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiTamTruQuanHuyenId(phieuThongTinVeNguoiCoTienSu.getNoiTamTruQuanHuyenId());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiTamTruPhuongXaId(phieuThongTinVeNguoiCoTienSu.getNoiTamTruPhuongXaId());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiThuongTruDiaChi(phieuThongTinVeNguoiCoTienSu.getNoiThuongTruDiaChi());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiThuongTruTinhId(phieuThongTinVeNguoiCoTienSu.getNoiThuongTruTinhId());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiThuongTruQuanHuyenId(phieuThongTinVeNguoiCoTienSu.getNoiThuongTruQuanHuyenId());
        phieuThongTinVeNguoiCoTienSuImpl.setNoiThuongTruPhuongXaId(phieuThongTinVeNguoiCoTienSu.getNoiThuongTruPhuongXaId());
        phieuThongTinVeNguoiCoTienSuImpl.setHoTenVoHoacChong(phieuThongTinVeNguoiCoTienSu.getHoTenVoHoacChong());
        phieuThongTinVeNguoiCoTienSuImpl.setHoTenCha(phieuThongTinVeNguoiCoTienSu.getHoTenCha());
        phieuThongTinVeNguoiCoTienSuImpl.setHoTenMe(phieuThongTinVeNguoiCoTienSu.getHoTenMe());

        return phieuThongTinVeNguoiCoTienSuImpl;
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
     *
     * @param primaryKey the primary key of the phieu thong tin ve nguoi co tien su
     * @return the phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findByPrimaryKey(
        Serializable primaryKey)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = fetchByPrimaryKey(primaryKey);

        if (phieuThongTinVeNguoiCoTienSu == null) {
            if (_log.isWarnEnabled()) {
                _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }

            throw new NoSuchPhieuThongTinVeNguoiCoTienSuException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
                primaryKey);
        }

        return phieuThongTinVeNguoiCoTienSu;
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su with the primary key or throws a {@link qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException} if it could not be found.
     *
     * @param phieuThongTinVeNguoiCoTienSuId the primary key of the phieu thong tin ve nguoi co tien su
     * @return the phieu thong tin ve nguoi co tien su
     * @throws qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu findByPrimaryKey(
        long phieuThongTinVeNguoiCoTienSuId)
        throws NoSuchPhieuThongTinVeNguoiCoTienSuException, SystemException {
        return findByPrimaryKey((Serializable) phieuThongTinVeNguoiCoTienSuId);
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su with the primary key or returns <code>null</code> if it could not be found.
     *
     * @param primaryKey the primary key of the phieu thong tin ve nguoi co tien su
     * @return the phieu thong tin ve nguoi co tien su, or <code>null</code> if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByPrimaryKey(
        Serializable primaryKey) throws SystemException {
        PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = (PhieuThongTinVeNguoiCoTienSu) EntityCacheUtil.getResult(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
                PhieuThongTinVeNguoiCoTienSuImpl.class, primaryKey);

        if (phieuThongTinVeNguoiCoTienSu == _nullPhieuThongTinVeNguoiCoTienSu) {
            return null;
        }

        if (phieuThongTinVeNguoiCoTienSu == null) {
            Session session = null;

            try {
                session = openSession();

                phieuThongTinVeNguoiCoTienSu = (PhieuThongTinVeNguoiCoTienSu) session.get(PhieuThongTinVeNguoiCoTienSuImpl.class,
                        primaryKey);

                if (phieuThongTinVeNguoiCoTienSu != null) {
                    cacheResult(phieuThongTinVeNguoiCoTienSu);
                } else {
                    EntityCacheUtil.putResult(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
                        PhieuThongTinVeNguoiCoTienSuImpl.class, primaryKey,
                        _nullPhieuThongTinVeNguoiCoTienSu);
                }
            } catch (Exception e) {
                EntityCacheUtil.removeResult(PhieuThongTinVeNguoiCoTienSuModelImpl.ENTITY_CACHE_ENABLED,
                    PhieuThongTinVeNguoiCoTienSuImpl.class, primaryKey);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return phieuThongTinVeNguoiCoTienSu;
    }

    /**
     * Returns the phieu thong tin ve nguoi co tien su with the primary key or returns <code>null</code> if it could not be found.
     *
     * @param phieuThongTinVeNguoiCoTienSuId the primary key of the phieu thong tin ve nguoi co tien su
     * @return the phieu thong tin ve nguoi co tien su, or <code>null</code> if a phieu thong tin ve nguoi co tien su with the primary key could not be found
     * @throws SystemException if a system exception occurred
     */
    @Override
    public PhieuThongTinVeNguoiCoTienSu fetchByPrimaryKey(
        long phieuThongTinVeNguoiCoTienSuId) throws SystemException {
        return fetchByPrimaryKey((Serializable) phieuThongTinVeNguoiCoTienSuId);
    }

    /**
     * Returns all the phieu thong tin ve nguoi co tien sus.
     *
     * @return the phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findAll()
        throws SystemException {
        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
    }

    /**
     * Returns a range of all the phieu thong tin ve nguoi co tien sus.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param start the lower bound of the range of phieu thong tin ve nguoi co tien sus
     * @param end the upper bound of the range of phieu thong tin ve nguoi co tien sus (not inclusive)
     * @return the range of phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findAll(int start, int end)
        throws SystemException {
        return findAll(start, end, null);
    }

    /**
     * Returns an ordered range of all the phieu thong tin ve nguoi co tien sus.
     *
     * <p>
     * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
     * </p>
     *
     * @param start the lower bound of the range of phieu thong tin ve nguoi co tien sus
     * @param end the upper bound of the range of phieu thong tin ve nguoi co tien sus (not inclusive)
     * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
     * @return the ordered range of phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public List<PhieuThongTinVeNguoiCoTienSu> findAll(int start, int end,
        OrderByComparator orderByComparator) throws SystemException {
        boolean pagination = true;
        FinderPath finderPath = null;
        Object[] finderArgs = null;

        if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
                (orderByComparator == null)) {
            pagination = false;
            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
            finderArgs = FINDER_ARGS_EMPTY;
        } else {
            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
            finderArgs = new Object[] { start, end, orderByComparator };
        }

        List<PhieuThongTinVeNguoiCoTienSu> list = (List<PhieuThongTinVeNguoiCoTienSu>) FinderCacheUtil.getResult(finderPath,
                finderArgs, this);

        if (list == null) {
            StringBundler query = null;
            String sql = null;

            if (orderByComparator != null) {
                query = new StringBundler(2 +
                        (orderByComparator.getOrderByFields().length * 3));

                query.append(_SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU);

                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator);

                sql = query.toString();
            } else {
                sql = _SQL_SELECT_PHIEUTHONGTINVENGUOICOTIENSU;

                if (pagination) {
                    sql = sql.concat(PhieuThongTinVeNguoiCoTienSuModelImpl.ORDER_BY_JPQL);
                }
            }

            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(sql);

                if (!pagination) {
                    list = (List<PhieuThongTinVeNguoiCoTienSu>) QueryUtil.list(q,
                            getDialect(), start, end, false);

                    Collections.sort(list);

                    list = new UnmodifiableList<PhieuThongTinVeNguoiCoTienSu>(list);
                } else {
                    list = (List<PhieuThongTinVeNguoiCoTienSu>) QueryUtil.list(q,
                            getDialect(), start, end);
                }

                cacheResult(list);

                FinderCacheUtil.putResult(finderPath, finderArgs, list);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(finderPath, finderArgs);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return list;
    }

    /**
     * Removes all the phieu thong tin ve nguoi co tien sus from the database.
     *
     * @throws SystemException if a system exception occurred
     */
    @Override
    public void removeAll() throws SystemException {
        for (PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu : findAll()) {
            remove(phieuThongTinVeNguoiCoTienSu);
        }
    }

    /**
     * Returns the number of phieu thong tin ve nguoi co tien sus.
     *
     * @return the number of phieu thong tin ve nguoi co tien sus
     * @throws SystemException if a system exception occurred
     */
    @Override
    public int countAll() throws SystemException {
        Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
                FINDER_ARGS_EMPTY, this);

        if (count == null) {
            Session session = null;

            try {
                session = openSession();

                Query q = session.createQuery(_SQL_COUNT_PHIEUTHONGTINVENGUOICOTIENSU);

                count = (Long) q.uniqueResult();

                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
                    FINDER_ARGS_EMPTY, count);
            } catch (Exception e) {
                FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
                    FINDER_ARGS_EMPTY);

                throw processException(e);
            } finally {
                closeSession(session);
            }
        }

        return count.intValue();
    }

    /**
     * Initializes the phieu thong tin ve nguoi co tien su persistence.
     */
    public void afterPropertiesSet() {
        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
                    com.liferay.util.service.ServiceProps.get(
                        "value.object.listener.qldc.pm.tiensu.model.PhieuThongTinVeNguoiCoTienSu")));

        if (listenerClassNames.length > 0) {
            try {
                List<ModelListener<PhieuThongTinVeNguoiCoTienSu>> listenersList = new ArrayList<ModelListener<PhieuThongTinVeNguoiCoTienSu>>();

                for (String listenerClassName : listenerClassNames) {
                    listenersList.add((ModelListener<PhieuThongTinVeNguoiCoTienSu>) InstanceFactory.newInstance(
                            getClassLoader(), listenerClassName));
                }

                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
            } catch (Exception e) {
                _log.error(e);
            }
        }
    }

    public void destroy() {
        EntityCacheUtil.removeCache(PhieuThongTinVeNguoiCoTienSuImpl.class.getName());
        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
        FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }
}
